package com.ruoyi.vehicle.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.vehicle.domain.RouteStationRealtion;
import com.ruoyi.vehicle.service.IRouteStationRealtionService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 站点关联Controller
 * 
 * @author yyj
 * @date 2025-08-16
 */
@RestController
@RequestMapping("/realtion")
public class RouteStationRealtionController extends BaseController
{
    @Autowired
    private IRouteStationRealtionService routeStationRealtionService;

    /**
     * 查询站点关联列表
     */
    @RequiresPermissions("vehicle:realtion:list")
    @GetMapping("/list")
    public TableDataInfo list(RouteStationRealtion routeStationRealtion)
    {
        startPage();
        List<RouteStationRealtion> list = routeStationRealtionService.selectRouteStationRealtionList(routeStationRealtion);
        return getDataTable(list);
    }

    /**
     * 导出站点关联列表
     */
    @RequiresPermissions("vehicle:realtion:export")
    @Log(title = "站点关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RouteStationRealtion routeStationRealtion)
    {
        List<RouteStationRealtion> list = routeStationRealtionService.selectRouteStationRealtionList(routeStationRealtion);
        ExcelUtil<RouteStationRealtion> util = new ExcelUtil<RouteStationRealtion>(RouteStationRealtion.class);
        util.exportExcel(response, list, "站点关联数据");
    }

    /**
     * 获取站点关联详细信息
     */
    @RequiresPermissions("vehicle:realtion:query")
    @GetMapping(value = "/{realtionId}")
    public AjaxResult getInfo(@PathVariable("realtionId") Long realtionId)
    {
        return success(routeStationRealtionService.selectRouteStationRealtionByRealtionId(realtionId));
    }

    /**
     * 新增站点关联
     */
    @RequiresPermissions("vehicle:realtion:add")
    @Log(title = "站点关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RouteStationRealtion routeStationRealtion)
    {
        return toAjax(routeStationRealtionService.insertRouteStationRealtion(routeStationRealtion));
    }

    /**
     * 修改站点关联
     */
    @RequiresPermissions("vehicle:realtion:edit")
    @Log(title = "站点关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RouteStationRealtion routeStationRealtion)
    {
        return toAjax(routeStationRealtionService.updateRouteStationRealtion(routeStationRealtion));
    }

    /**
     * 删除站点关联
     */
    @RequiresPermissions("vehicle:realtion:remove")
    @Log(title = "站点关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{realtionIds}")
    public AjaxResult remove(@PathVariable Long[] realtionIds)
    {
        return toAjax(routeStationRealtionService.deleteRouteStationRealtionByRealtionIds(realtionIds));
    }
}
